package net.xdclass.jvm;

/**
 * @author zhaowei
 * @Description TODO
 * @Remark 有问题直接联系我
 * @Version 1.0
 **/
public class StackFrameDemo {

    public static void main(String[] args) {
        StackFrameDemo demo = new StackFrameDemo();
        demo.method1();
    }

    public void method1() {
        String str = "Hello";
        method2(str);
        System.out.println("method1--完成");
    }

    public void method2(String str) {
        int num = 123;
        method3(str, num);
        System.out.println("method2--完成");
    }

    public void method3(String str, int num) {
        double d = 3.14;
        method4(str, num, d);
        System.out.println("method3--完成");
    }

    public void method4(String str, int num, double d){
        //查看当前栈信息
        System.out.println("打印当前栈帧信息");
        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
        for(StackTraceElement element : stackTrace){
            System.out.println(element.toString());
        }
        System.out.println("method4--完成");
    }

}

